package com.devilvan.betrice.aiqicha.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.aiqicha.dto.AiqichaDirectorsDto;
import com.devilvan.betrice.aiqicha.po.AiqichaDirectorsPo;
import com.devilvan.betrice.aiqicha.service.AiqichaDirectorsService;
import com.devilvan.betrice.aiqicha.mapper.AiqichaDirectorsMapper;
import com.devilvan.betrice.aiqicha.repository.AiqichaDirectorsRepository;
import org.springframework.stereotype.Service;
import com.devilvan.betrice.util.UCopy;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description 爱企查-主要人员信息 业务逻辑类
* @date 2022-09-24
*/
@Service
public class AiqichaDirectorsServiceImpl extends ServiceImpl<AiqichaDirectorsMapper, AiqichaDirectorsPo> implements AiqichaDirectorsService {
    @Resource(name = "aiqichaDirectorsRepository")
    private AiqichaDirectorsRepository aiqichaDirectorsRepository;

    @Override
    public AiqichaDirectorsPo saveUpdate(AiqichaDirectorsDto aiqichaDirectorsDto) {
        AiqichaDirectorsPo aiqichaDirectorsPo = new AiqichaDirectorsPo();
        UCopy.fullCopy(aiqichaDirectorsDto, aiqichaDirectorsPo);
        return aiqichaDirectorsRepository.saveAndFlush(aiqichaDirectorsPo);
    }

    @Override
    public List<AiqichaDirectorsPo> saveUpdateBatch(List<AiqichaDirectorsDto> list) {
        List<AiqichaDirectorsPo> aiqichaDirectorsPoList = UCopy.fullCopyCollections(list, AiqichaDirectorsPo.class);
        return aiqichaDirectorsRepository.saveAllAndFlush(aiqichaDirectorsPoList);
    }
}
